var dataArr = [];
//获取用户数量
$.ajax({
    type: 'get',
    url: '/users',
    async: false,
    success: function(response) {
        dataArr.push(response.length);
    }
})
//获取推荐的数量
$.ajax({
    type: 'get',
    url: '/posts/count',
    async: false,
    success: function(response) {
        dataArr.push(response.postCount);
        dataArr.push(response.draftCount);
    }
})

//获取地区的数量
$.ajax({
    type: 'get',
    url: '/categories/count',
    async: false,
    success: function(response) {
        dataArr.push(response.categoryCount);
    }
})

//获取评论数量
$.ajax({
    type: 'get',
    url: '/comments/count',
    async: false,
    success: function(response) {
        dataArr.push(response.commentCount);

    }
})
var chartDom = document.getElementById('main');
var myChart = echarts.init(chartDom);
var option;

option = {
    title: {
        text: 'Diners 数据统计'
    },
    tooltip: {},
    legend: {
        data: ['数量']
    },
    xAxis: {
        data: ["用户数量", "美食推荐", "推荐草稿", "美食地区", "用户评论"]
    },
    yAxis: {},
    series: [{
        name: '数量',
        type: 'bar',
        data: dataArr
    }]
};

option && myChart.setOption(option);